package tracyeminem.com.tiktokcomment.comment

import com.drakeet.multitype.sample.weibo.Weibo
import com.drakeet.multitype.sample.weibo.WeiboContent
import com.drakeet.multitype.sample.weibo.WeiboContentDeserializer
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import java.util.ArrayList

/**
 * Describe:
 * Author: lifei
 * Date: 2020/11/5
 * Email: lifei022454@gtjas.com
 */

class CommentJsonParser {
    val GSON = GsonBuilder()
            .registerTypeAdapter(WeiboContent::class.java, WeiboContentDeserializer())
            .create()!!

    fun fromJson(json: String): List<Weibo> {
        return GSON.fromJson(json, object : TypeToken<ArrayList<Weibo>>() {}.type)
    }

    companion object {
        val json = """
            {
                "data": {
                    "hotElements": [
                        {
                            "comment": {
                                "admirenums": 2,
                                "auditor": "孙大申",
                                "authtype": 0,
                                "belongtype": 0,
                                "collectnums": 0,
                                "content": "评论测试60076-点赞专用1",
                                "cpfrom": 2,
                                "createtime": 1597805093000,
                                "creator": "梁山伯与祝英台杠",
                                "employeeid": "020293",
                                "exttype": 1,
                                "flowflag": 0,
                                "flowtime": 20200819,
                                "handler": "孙大申",
                                "hotreplycontent": "回复评论60077-回复评论点赞1",
                                "hotreplycreator": "大魔导师刘秀",
                                "hotreplyusercode": "60077",
                                "id": 17286496075649024,
                                "ncommentflag": 0,
                                "postid": 8057688,
                                "pushtype": 0,
                                "readmark": 0,
                                "replyid": 17334117691559936,
                                "replynums": 5,
                                "status": 1,
                                "title": "",
                                "topflag": 0,
                                "treadnums": 0,
                                "type": 0,
                                "updatetime": 1597805208000,
                                "usercode": "60076",
                                "usertype": 0,
                                "wordnums": 8
                            },
                            "replist": [
                                {
                                    "admirenums": 0,
                                    "auditflag": 0,
                                    "auditor": "",
                                    "belongtype": 0,
                                    "collectnums": 0,
                                    "commentid": 17286496075649024,
                                    "content": "回复评论60077-回复评论点赞666",
                                    "cpfrom": 2,
                                    "createtime": 1598336509000,
                                    "creator": "大魔导师刘秀",
                                    "id": 19515415625469952,
                                    "postid": 8057688,
                                    "readmark": 0,
                                    "replyid": 0,
                                    "replynums": 0,
                                    "status": 0,
                                    "type": 1,
                                    "updatetime": 1598336509000,
                                    "usercode": "60077"
                                },
                                {
                                    "admirenums": 0,
                                    "auditflag": 0,
                                    "auditor": "孙大申",
                                    "belongtype": 0,
                                    "collectnums": 0,
                                    "commentid": 17286496075649024,
                                    "content": "回复评论60076-回复评论点赞5",
                                    "cpfrom": 2,
                                    "createtime": 1597816994000,
                                    "creator": "大魔导师刘秀",
                                    "employeeid": "020293",
                                    "handler": "孙大申",
                                    "id": 17336409987747840,
                                    "postid": 8057688,
                                    "readmark": 0,
                                    "replyid": 0,
                                    "replynums": 0,
                                    "status": 1,
                                    "type": 1,
                                    "updatetime": 1597817274000,
                                    "usercode": "60076"
                                },
                                {
                                    "admirenums": 0,
                                    "auditflag": 0,
                                    "auditor": "孙大申",
                                    "belongtype": 0,
                                    "collectnums": 0,
                                    "commentid": 17286496075649024,
                                    "content": "回复评论60076-回复评论点赞4",
                                    "cpfrom": 2,
                                    "createtime": 1597816987000,
                                    "creator": "大魔导师刘秀",
                                    "employeeid": "020293",
                                    "handler": "孙大申",
                                    "id": 17336380191412224,
                                    "postid": 8057688,
                                    "readmark": 0,
                                    "replyid": 0,
                                    "replynums": 0,
                                    "status": 1,
                                    "type": 1,
                                    "updatetime": 1597817013000,
                                    "usercode": "60076"
                                },
                                {
                                    "admirenums": 0,
                                    "auditflag": 0,
                                    "auditor": "孙大申",
                                    "belongtype": 0,
                                    "collectnums": 0,
                                    "commentid": 17286496075649024,
                                    "content": "回复评论60077-回复评论点赞3",
                                    "cpfrom": 2,
                                    "createtime": 1597816522000,
                                    "creator": "大魔导师刘秀",
                                    "employeeid": "020293",
                                    "handler": "孙大申",
                                    "id": 17334433229049856,
                                    "postid": 8057688,
                                    "readmark": 0,
                                    "replyid": 0,
                                    "replynums": 0,
                                    "status": 1,
                                    "type": 1,
                                    "updatetime": 1597816739000,
                                    "usercode": "60077"
                                },
                                {
                                    "admirenums": 0,
                                    "auditflag": 0,
                                    "auditor": "孙大申",
                                    "belongtype": 0,
                                    "collectnums": 0,
                                    "commentid": 17286496075649024,
                                    "content": "回复评论60077-回复评论点赞2",
                                    "cpfrom": 2,
                                    "createtime": 1597816508000,
                                    "creator": "大魔导师刘秀",
                                    "employeeid": "020293",
                                    "handler": "孙大申",
                                    "id": 17334371182710784,
                                    "postid": 8057688,
                                    "readmark": 0,
                                    "replyid": 0,
                                    "replynums": 0,
                                    "status": 1,
                                    "type": 1,
                                    "updatetime": 1597816742000,
                                    "usercode": "60077"
                                },
                                {
                                    "admirenums": 2,
                                    "auditflag": 0,
                                    "auditor": "孙大申",
                                    "belongtype": 0,
                                    "collectnums": 0,
                                    "commentid": 17286496075649024,
                                    "content": "回复评论60077-回复评论点赞1",
                                    "cpfrom": 2,
                                    "createtime": 1597816447000,
                                    "creator": "大魔导师刘秀",
                                    "employeeid": "020293",
                                    "handler": "孙大申",
                                    "id": 17334117691559936,
                                    "postid": 8057688,
                                    "readmark": 0,
                                    "replyid": 0,
                                    "replynums": 0,
                                    "status": 1,
                                    "type": 1,
                                    "updatetime": 1598292000000,
                                    "usercode": "60077"
                                }
                            ]
                        }
                    ],
                    "list": [
                        {
                            "comment": {
                                "admirenums": 0,
                                "auditor": "",
                                "authtype": 0,
                                "belongtype": 0,
                                "collectnums": 0,
                                "content": "http://101.231.93.226/social/pictures/userforum/0/60077/1597818486411.png评论测试60077-点赞专用1",
                                "cpfrom": 2,
                                "createtime": 1597908692000,
                                "creator": "大魔导师刘秀",
                                "flowflag": 0,
                                "flowtime": 20200820,
                                "id": "17721020983021568",
                                "ncommentflag": 0,
                                "postid": 8057688,
                                "pushtype": 0,
                                "readmark": 0,
                                "replyid": 0,
                                "replynums": 0,
                                "status": 0,
                                "title": "",
                                "topflag": 0,
                                "treadnums": 0,
                                "type": 0,
                                "updatetime": 1597908692000,
                                "usercode": "60077",
                                "usertype": 0,
                                "wordnums": 8
                            },
                            "replist": []
                        }
                    ]
                },
                "resultCode": "0",
                "resultMsg": "success"
            }
        """.trimIndent()
    }
}

